package com.woniux.entity.factoryUtils;

import com.woniux.entity.entity.Animal;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author 佘赛飞
 * @create 2021 -11 -09 4:32 PM
 */
public class ThirdFactory {

    public Animal doAnimal(){
        Properties properties = new Properties();
        InputStream resourceAsStream = ThirdFactory.class.getResourceAsStream("doAnimal.properties");
        String animalName="";
        Animal animal=null;

        try {
            properties.load(resourceAsStream);
            animalName=properties.getProperty("animal");
            animal=(Animal) Class.forName(animalName).newInstance();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
            return animal;
    }
}
